﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Galaxy.AutoCAD.Options;
using AutoCADApp = Autodesk.AutoCAD.ApplicationServices;

namespace Galaxy.AutoCAD.Windows
{
    public partial class ProofreadWindow : Form
    {
        public ProofreadWindow()
        {
            InitializeComponent();
        }

        private void ProofreadWindow_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            textBox1.SelectAll();
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            textBox2.SelectAll();
        }

        private void textBox3_Click(object sender, EventArgs e)
        {
            textBox3.SelectAll();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            GeneralOptionTool.ProofreadPass = "1";
            if (textBox1.Text == "")
            {
                AutoCADApp.Application.ShowAlertDialog("请输入有效值!");
                textBox1.Focus();
                return;
            }
            else
            {
                GeneralOptionTool.ProofreadStandardClauses = textBox1.Text;
            }
            if (textBox2.Text == "")
            {
                AutoCADApp.Application.ShowAlertDialog("请输入有效值!");
                textBox2.Focus();
                return;
            }
            else
            {
                GeneralOptionTool.ProofreadStandardNumber = textBox2.Text;
            }
            if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false && radioButton4.Checked == false)
            {
                AutoCADApp.Application.ShowAlertDialog("请选择有效的规范等级!");
                return;
            }
            else
            {
                if (radioButton1.Checked == true)
                {
                    GeneralOptionTool.ProofreadStandardClass = "A";
                }
                if (radioButton2.Checked == true)
                {
                    GeneralOptionTool.ProofreadStandardClass = "B";
                }
                if (radioButton3.Checked == true)
                {
                    GeneralOptionTool.ProofreadStandardClass = "C";
                }
                if (radioButton4.Checked == true)
                {
                    GeneralOptionTool.ProofreadStandardClass = "D";
                }
            }
            int proofreadStandradGrade;
            if (int.TryParse(textBox3.Text, out proofreadStandradGrade))
            {
                if (proofreadStandradGrade >= 0 && proofreadStandradGrade <= 100)
                {
                    GeneralOptionTool.ProofreadStandardGrade = proofreadStandradGrade;
                }
                else
                {
                    AutoCADApp.Application.ShowAlertDialog("请输入有效值!");
                    textBox3.Focus();
                    return;
                }
            }
            else
            {
                AutoCADApp.Application.ShowAlertDialog("请输入有效值!");
                textBox3.Focus();
                return;
            }
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            GeneralOptionTool.ProofreadPass = "0";
            GeneralOptionTool.ProofreadStandardClauses = "";
            GeneralOptionTool.ProofreadStandardNumber = "";
            GeneralOptionTool.ProofreadStandardClass = "A";
            GeneralOptionTool.ProofreadStandardGrade = 0;
            this.Close();
        }
    }
}
